package com.dfrz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dfrz.entity.Utilrecommend;
import com.dfrz.entity.Video;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 29877
 */
@Mapper
public interface IVideoMapper extends BaseMapper<Video> {
    List<Video> selectLimit(@Param("index") Integer index, @Param("num") Integer num);
    @Select("select * from video where video_id=#{vid}")
    Video selectvideobyid(Integer vid);

    @Select("select * from video where video_title like #{word}")
    List<Video> selectvideobyname(String word);

    @Select("SELECT * FROM `video`  ORDER BY score desc limit 0,6")
    List<Video> selectorderbyscore();
    @Select("SELECT * FROM `video`  ORDER BY score desc limit 0,20")
    List<Video> selectorderbyscore2();

    Utilrecommend selectrecommend( @Param("id") int id);

    @Insert("insert into history(user_id,video_id,history_time) values(#{uid},#{vid},#{time})")
    void addhistory(@Param("uid") Integer uid,@Param("vid") Integer vid,@Param("time") String time);

    //通过uid和vid删除历史记录
    @Delete("delete from history where user_id=#{uid} and video_id=#{vid}")
    void  deleteHistorybyUidAndVid(@Param("uid") Integer uid,@Param("vid") Integer vid);

    //通过history_id删除历史记录
    @Delete("delete from history where history_id=#{hid}")
    void deletehistorybyid(Integer hid);

    List<Video> searchvideo(String word);
    List<Video> selectPageEdit(@Param("page")  int page,@Param("pageSize") int pageSize);
    List<Video>  selectEdidCount();
}
